<!--
  - Copyright (C) 2018-2019
  - All rights reserved, Designed By www.joolun.com
-->
<template>
  <div class="news-home">
    <div v-for="(news, index) in objData" :key="index" class="news-div">
      <a target="_blank" :href="news.url" v-if="index == 0">
        <div class="news-main">
          <div class="news-content">
            <!-- <img class="material-img" :src="news.thumb_url" height="100px" /> -->
            <el-image
              class="material-img"
              :src="news.thumb_url"
              style="height: 100px"
              :preview-src-list="[news.thumb_url]"
            />
            <div class="news-content-title">
              <span>{{ news.title }}</span>
            </div>
          </div>
        </div>
      </a>
      <a target="_blank" :href="news.url" v-if="index > 0">
        <div class="news-main-item">
          <div class="news-content-item">
            <div class="news-content-item-title">{{ news.title }}</div>
            <div class="news-content-item-img">
              <!-- <img class="material-img" :src="news.thumb_url" height="100%" /> -->
              <el-image
                class="material-img"
                :src="news.thumb_url"
                style="height: 100px"
                :preview-src-list="[news.thumb_url]"
              />
            </div>
          </div>
        </div>
      </a>
      <h6></h6>
      <el-row v-if="chooice" class="ope-row d_f ju_c">
        <el-button
          style="margin: 0 auto"
          size="small"
          type="success"
          @click="selectNewsMaterial(news)"
          >选择 <el-icon><Select /></el-icon
        ></el-button>
      </el-row>
    </div>
  </div>
</template>

<script>
export default {
  name: "wxNews",
  props: {
    objData: {
      type: Array,
    },
    chooice: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {};
  },
  computed() {
    // getData: {
    //   const newData = []
    //   this.objData.map((item) => {
    //     const newObj = {};
    //     newObj.media = item.content.media_id
    //     newObj.thumb_url = item.content.news_item[0].thumb_url
    //   });
    //   return
    // }
  },
  created() {},
  mounted() {},
  computed: {},
  methods: {
    selectNewsMaterial(item) {
      console.log(item);
      this.$emit("selectNewsMaterial", item);
    },
  },
};
</script>

<style lang="scss" scoped>
.news-home {
  background-color: #ffffff;
  width: 100%;
  margin: auto;
}
.news-main {
  width: 100%;
  margin: auto;
}
.news-content {
  background-color: #acadae;
  width: 100%;
  position: relative;
}
.news-content-title {
  display: inline-block;
  font-size: 12px;
  color: #ffffff;
  position: absolute;
  left: 0px;
  bottom: 0px;
  background-color: black;
  width: 98%;
  padding: 1%;
  opacity: 0.65;
  white-space: normal;
  box-sizing: unset !important;
}
.news-main-item {
  background-color: #ffffff;
  padding: 5px 0px;
  border-top: 1px solid #eaeaea;
}
.news-content-item {
  position: relative;
}
.news-content-item-title {
  display: inline-block;
  font-size: 10px;
  width: 70%;
  margin-left: 1%;
  white-space: normal;
}
.news-content-item-img {
  display: inline-block;
  width: 25%;
  background-color: #acadae;
  margin-right: 1%;
}
.material-img {
  width: 100%;
}
</style>
